<template>
    <div class="newsInfo-main">
        <h3 class="title">{{infoObj.title}}</h3>
        <p class="subtitle">
            <span>发表时间：{{infoObj.add_time}}</span>
            <span>点击：{{infoObj.click}}次</span>
        </p>
        <hr>
        <div class="content" v-html="infoObj.content"></div>
        <!-- 评论列表 -->
         <!-- 子组件渲染再父组件上 -->
         <comment-div :nid="id"></comment-div>

    </div>
</template>
<script>
// 引入子组件
import comment from "./subList/comment.vue";
export default {
    data() {
        return {
            id:this.$route.params.id,
            infoObj:{}
        }
    },
    created(){
        this.getInfoList()
    }, 
    methods:{
        getInfoList(){
           this.$http.get("api/getnew/"+this.id).then(result=>{
                 if(result.body.status==0){
                     this.infoObj= result.body.message[0];
                    // console.log(result.body);
                    
                 }
           })
        }
    },
    // 注册子组件、在父组件上
    components:{
        "comment-div":comment 
    }
}
</script>
<style lang="scss" scoped>
    .newsInfo-main{
        color: red;
        text-align: center;
        .subtitle{
            width: 100%;
            display: flex;
            justify-content: space-between;
        }
    }
</style>